package com.zzy.threaddemo.newdemo;

import com.google.common.util.concurrent.FutureCallback;

/**
 * 定义一个FutureCallBack实现类
 */
public class FutureCallbackImpl implements FutureCallback<String> {
	private StringBuilder builder = new StringBuilder();
	
	private String theadName;  //线程名
	
	public FutureCallbackImpl(String theadName) {
		super();
		this.theadName = theadName;
	}

	public void onSuccess(String result) {
		builder.append(theadName).append(" successfully :").append(result);
		System.out.println(builder.toString());
	}

	public void onFailure(Throwable t) {
		builder.append(t.toString());
	}

	public String getCallbackResult() {
		return builder.toString();
	}

	
	
	
	
	
	
	
	
	public String getTheadName() {
		return theadName;
	}

	public void setTheadName(String theadName) {
		this.theadName = theadName;
	}
	
	
	
}